#!/usr/bin/perl -w
use Net::SSH::Expect;
$list='list.txt';
$results='results.txt';
open LIST , "<$list";
open RES, ">$results";

while (<LIST>) {
chomp;
$server = lc ($_);

        my $ssh = Net::SSH::Expect->new (
                    host => "$server",
                    user => 'ngscheck',
                    raw_pty => 1
                );
        $ssh->run_ssh() or die "SSH process couldn't start: $!";
        $version=$ssh->exec("cat /etc/issue");
        @output = split /\n/,$version;
        $i=1;
        foreach $out (@output) {
                if ($out =~ /Linux/) {
                        $pos=index($out, ']$' ,0);
                        $out = substr ($out,$pos+3);
                        print RES $server . "-----> " . $out . "\n";
                        $i++;
                }
                else {next;}
        }
        $ssh->close();
}

